package cn.com.suiyi.shixingshengxian.active.adapter;

import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import cn.com.suiyi.shixingshengxian.R;
import cn.com.suiyi.shixingshengxian.bean.ActiveBean;

/**
 * Created by Administrator on 2016/7/19.
 */
public class ActiveAdapter extends RecyclerView.Adapter<ActiveAdapter.ActiveViewHolder> {
    private List<ActiveBean.DataBean.ActivityBean> activeBeen;

    public ActiveAdapter(List<ActiveBean.DataBean.ActivityBean> activeBeen) {
        this.activeBeen = activeBeen;
    }

    @Override
    public ActiveViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        Log.i("tag", "onCreateViewHolder: ");
        ActiveViewHolder holder = null;
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_active, null);
        holder = new ActiveViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ActiveViewHolder holder, int position) {
        Log.i("tag", "onBindViewHolder: " + activeBeen.get(position).getTitle());
        holder.textView.setText(activeBeen.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return activeBeen.size();
    }

    class ActiveViewHolder extends RecyclerView.ViewHolder {
        TextView textView;

        public ActiveViewHolder(View itemView) {
            super(itemView);
            textView = (TextView) itemView.findViewById(R.id.textview_active);
        }
    }
}
